package test;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: fzykd
 * Date: 2023-01-10
 * Time: 18:36
 */

//单例模式 - 饿汉模式
class Singleton{
    private static Singleton instance = new Singleton();
    //构造函数防止修改
    private Singleton(){}
    //外面获取的函数
    public static Singleton getInstance(){
        return instance;
    }
}

public class Demo1 {
    public static void main(String[] args) {
        Singleton instance = Singleton.getInstance();
    }
}
